package com.ruoyi.parcel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;


import cn.hutool.core.util.NumberUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.parcel.domain.EPackageTable;
import com.ruoyi.parcel.service.IEPackageTableService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * EPackageTableController
 *
 * @author ruoyi
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/parcel/package")
public class EPackageTableController extends BaseController {
    @Autowired
    private IEPackageTableService ePackageTableService;


    /**
     * 查询EPackageTable列表
     */
    @RequiresPermissions("parcel:parcel:list")
    @GetMapping("/list")
    public TableDataInfo list(EPackageTable ePackageTable) {
        startPage();
        List<EPackageTable> list = ePackageTableService.selectEPackageTableList(ePackageTable);
        return getDataTable(list);
    }

    /**
     * 导出EPackageTable列表
     */
    @RequiresPermissions("parcel:parcel:export")
    @Log(title = "EPackageTable", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EPackageTable ePackageTable) {
        List<EPackageTable> list = ePackageTableService.selectEPackageTableList(ePackageTable);
        ExcelUtil<EPackageTable> util = new ExcelUtil<EPackageTable>(EPackageTable.class);
        util.exportExcel(response, list, "EPackageTable数据");
    }

    /**
     * 获取EPackageTable详细信息
     */
    @RequiresPermissions("parcel:parcel:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(ePackageTableService.selectEPackageTableById(id));
    }

    /**
     * 新增EPackageTable
     */
    @RequiresPermissions("parcel:parcel:add")
    @Log(title = "EPackageTable", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EPackageTable ePackageTable) {
        return toAjax(ePackageTableService.insertEPackageTable(ePackageTable));
    }

    /**
     * 修改EPackageTable
     */
    @RequiresPermissions("parcel:parcel:edit")
    @Log(title = "EPackageTable", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EPackageTable ePackageTable) {
        return toAjax(ePackageTableService.updateEPackageTable(ePackageTable));
    }

    /**
     * 删除EPackageTable
     */
    @RequiresPermissions("parcel:parcel:remove")
    @Log(title = "EPackageTable", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ePackageTableService.deleteEPackageTableByIds(ids));
    }
    /**
     * 发送验证码
     */
    @PostMapping("/{phoneNumber}")
    public String sendSms(@PathVariable String phoneNumber) {
        return ePackageTableService.sendSms(phoneNumber, "");
    }



}
